<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="UTF-8">
        <title>Excluir Usuário</title>
        <link rel="stylesheet" href="../css/Tables.css" />
    </head>
    <body>
        
        <fieldset>
            <form>
                <label>Pesquisar Usuario:</label>
                <input type="text" name="CampPesquisar" />
                <input type="button" name="pesquisar" value="Pesquisar" />
            </form>
        </fieldset>
        
        <?php
        require("../../_app/Config.inc.php");
        
        echo "<table><tr><th>Id</th><th>CPF</th><th>E-mail</th><th>Nivel de acesso</th><th>Excluir</th></tr>";
        $listar = new Read();
        $listar->ExeRead('usuario');        
        if($listar->getResult()){
            foreach ($listar->getResult() as $lista):
                echo "<tr><td>{$lista['Id_Usuario']}</td><td>{$lista['CPF_Usuario']}</td><td>{$lista['Email_usuario']}</td><td>{$lista['Nivel_Usuario']}</td><td><a href=\"ExcluirUsuario.php?del={$lista['Id_Usuario']}\" >Excluir</a></td></tr>";
            endforeach;
        }        
        echo "</table>";
        if (!empty($_GET['del'])) {
            $delete = $_GET['del'];
            
            $del = new Delete();
            $del->ExeDelete('usuario', 'WHERE Id_Usuario= :delete',"delete={$delete}" );
            
            if ($del->getResult()):
                echo "{$del->getRowCount()} registro(s) removidos com sucesso!";
            endif;
        }
        
        
        ?>
        
    </body>
</html>
